/**
 * 2025/01/01 - 2025/12/31
 */
package com.snail.server.database.engine.ddl.field.controller;

import com.snail.server.database.engine.ddl.field.dto.FieldAddDTO;
import com.snail.server.database.engine.ddl.field.manager.FieldManager;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * @author zgadmin
 * @date 2025/8/29 14:29
 *
 */
@Api(tags = {"字段管理"})
@RestController
@RequestMapping("/data-source/{dataSourceId}/table/{tableId}/field")
public class FieldController {

    @Resource
    FieldManager fieldManager;

    @PostMapping
    public void create(@PathVariable("dataSourceId") Long dataSourceId, @PathVariable("tableId") Long tableId, @RequestBody FieldAddDTO fieldCreate){
        fieldManager.create(dataSourceId, tableId, fieldCreate);
    }

    @PutMapping("/{fileId}")
    public void alter(@PathVariable("dataSourceId") Long dataSourceId, @PathVariable("tableId") Long tableId, @PathVariable("fileId") Long fileId){
        fieldManager.alter(dataSourceId, tableId, fileId);
    }

    @GetMapping("/{fileId}")
    public void queryById(@PathVariable("dataSourceId") Long dataSourceId, @PathVariable("tableId") Long tableId, @PathVariable("fileId") Long fileId){
        fieldManager.queryById(dataSourceId, tableId, fileId);
    }

    @DeleteMapping("/{fileId}")
    public void delete(@PathVariable("dataSourceId") Long dataSourceId, @PathVariable("tableId") Long tableId, @PathVariable("fileId") Long fileId){
        fieldManager.delete(dataSourceId, tableId, fileId);
    }

}